Skip to content

add ProgressMeter extension module#164

Open
marius311 wants to merge 4 commits intoJuliaFolds2:masterfrom
marius311:progressmeter
Open

add ProgressMeter extension module#164
marius311 wants to merge 4 commits intoJuliaFolds2:masterfrom
marius311:progressmeter

Conversation

@marius311
Copy link

Fixes #59

E.g.

julia> using ProgressMeter, OhMyThreads

julia> @showprogress tmap(i -> (sleep(0.1); i^2), 1:10)
Progress: 100%|██████████████████| Time: 0:00:00
10-element Vector{Int64}:
...

I have a test file I used that basically does that command for everything, but I didn't commit since it didn't feel right, but let me know.

Note the use of ::Function (rather than ::Callable) just matches what ProgressMeter does to avoid any ambiguities.

@codecov-commenter
Copy link

codecov-commenter commented Feb 1, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.67%. Comparing base (cba9127) to head (a9fa144).
⚠️ Report is 150 commits behind head on master.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #164      +/-   ##
==========================================
- Coverage   90.24%   89.67%   -0.58%     
==========================================
  Files           3        9       +6     
  Lines          82      639     +557     
==========================================
+ Hits           74      573     +499     
- Misses          8       66      +58     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@carstenbauer
Copy link
Member

Thanks for the PR! Can we add some tests for this somehow?

@marius311
Copy link
Author

Done.

@carstenbauer
Copy link
Member

Needs an entry in CHANGELOG.md

Copy link
Member

@MasonProtter MasonProtter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, thank you! Is there a way to make ProgressMeter.jl understand @tasks as well? Im guessing not, but thought I should ask.

@marius311
Copy link
Author

marius311 commented Feb 6, 2026

Added changelog. On @tasks yea there's no super clean way I'd say, @showprogress expects the map-like call as the first and only expression. I suppose one avenue might be to try and PR that package so that it looks at the final expression in the block it gets, which might a reasonable assumption, and then would immediately work here since the last expression is the tforeach which now works. But yea otherwise I'd say beyond this scope.

julia> @macroexpand @tasks for i=1:10; sleep(0.1); end
:(let
      #= /Users/marius/work/ohmythreads_progress/OhMyThreads/src/macro_impl.jl:127 =#
      begin
          #= /Users/marius/work/ohmythreads_progress/OhMyThreads/src/macro_impl.jl:103 =#
          begin
              #= /Users/marius/work/ohmythreads_progress/OhMyThreads/src/macro_impl.jl:260 =#
          end
          #= /Users/marius/work/ohmythreads_progress/OhMyThreads/src/macro_impl.jl:104 =#
          begin
              #= /Users/marius/work/ohmythreads_progress/OhMyThreads/src/macro_impl.jl:280 =#
          end
          #= /Users/marius/work/ohmythreads_progress/OhMyThreads/src/macro_impl.jl:105 =#
          nothing
          #= /Users/marius/work/ohmythreads_progress/OhMyThreads/src/macro_impl.jl:106 =#
          local function var"#1#mapping_function"(i)
                  #= /Users/marius/work/ohmythreads_progress/OhMyThreads/src/macro_impl.jl:71 =#
                  #= /Users/marius/work/ohmythreads_progress/OhMyThreads/src/macro_impl.jl:72 =#
                  begin
                      #= REPL[6]:1 =#
                      sleep(0.1)
                      #= REPL[6]:1 =#
                  end
              end
          #= /Users/marius/work/ohmythreads_progress/OhMyThreads/src/macro_impl.jl:107 =#
          OhMyThreads.tforeach(var"#1#mapping_function", 1:10; )
      end
  end)

julia> @macroexpand @showprogress @tasks for i=1:10; sleep(0.1); end
ERROR: ArgumentError: Final argument to @showprogress must be a for loop, comprehension, or a map-like function; got #= REPL[7]:1 =# @tasks for i = 1:10
        #= REPL[7]:1 =#
        sleep(0.1)
        #= REPL[7]:1 =#
    end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

showprogress setting

4 participants